<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{margin: 0;padding: 0;}
			h2{text-align: center;background: deepskyblue;color: brown;}
			h2 span{float: right;margin-right: 50px;}
			.aaa{width: 300px;
					height: 200px;
					text-align: center;
					position: absolute;
					top: 0;left:0;right: 0;bottom: 0;
					margin: auto;
					background: darkslategray;
					color: white;
					border-radius: 30px;
					}
			.aaa input{width: 150px;
						height: 30px;
						border-radius: 10px;
						border: none;
						margin:20px;}
			.aaa button{width: 80px;
							height: 30px;
							background: deepskyblue;
							border-radius: 10px;
							border: none;}
			#zhuce{display: none;}
		</style>
	</head>
	<body>
		<h2>图书管理系统<span>注册</span></h2>
		<div id="load" class="aaa">
			用户名：<input type="text" name="username" id="zxc" value="" /><br />
			密&nbsp;&nbsp;&nbsp;码：<input type="password" name="password" id="pwd" value="" />
			<button id="dl">登录</button>
		</div>
		<div id="zhuce" class="aaa">
			用户名：<input type="text" name="username" id="xm" value="" /><br />
			密&nbsp;&nbsp;&nbsp;码：<input type="password" name="password" id="mm" value="" />
			<button id="zc">注册</button>
		</div>
	</body>
	<script src="jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$("span").on("click",function(){
			$("#zhuce").css("display","block")
			$("#load").css("display","none")
		})
		$("#zc").on("click",function(){
			$("#zhuce").css("display","none")
			$("#load").css("display","block")
			var xx={
				username:xm.value,
				password:mm.value
			}
			$.ajax({
				url:"http://localhost:1200/users",
				type:"post",
				data:xx,
				success:function(data){
					console.log(data)
				},
				error:function(err){
					console.log(err)
				}
			})
		})
			
		$("#dl").on("click",function(){
			var ss={
				username:zxc.value,
				password:pwd.value
			}
			console.log(1)
//			$.post("http://localhost:1200/users/login"),{"username":zxc.value,"passward":pwd.value},function(data){
//				console.log(data)
//			}
			$.ajax({
				url:"http://localhost:1200/users/login",
				type:"post",
				data:ss,
				success:function(data){
					location.href="books.html"
					localStorage.setItem('name',zxc.value)
//					window.open("books.html")
				},
				error:function(err){
					alert("用户名或密码不存在")
				}
			})
		})
	</script>
</html>
